{{!
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
}}

<div id="installOptions">
  <h2>{{t installer.step2.header}}</h2>

  <p class="alert alert-info">{{t installer.step2.body}}</p>

  <div id="targetHosts">
    <h5>{{t installer.step2.targetHosts}}</h5>

    <div {{bindAttr class="hostsError:error :control-group :target-hosts-input"}}>
      <p>{{t installer.step2.targetHosts.info}}. {{t installer.step2.orUse}}
        <a href="javascript:void(null)"
           rel="popover"
          {{translateAttr title="installer.step2.hostPattern.tooltip.title" data-content="installer.step2.hostPattern.tooltip.content"}}>
          {{t installer.step2.hostPattern.tooltip.title}}
        </a>
      </p>

      <div class="controls">
        {{view Ember.TextArea id="host-names" class="span6" valueBinding="content.installOptions.hostNames" rows="5"
        placeholder="host names"}}
        {{#if hostsError}}
          <p class="help-inline">{{hostsError}}</p>
        {{/if}}
      </div>
    </div>
  </div>

  <div id="hostConnectivity">
    <div class="ambari-agents">
      <h5>{{t installer.step2.sshKey}}</h5>

      <label class="radio">
        {{view view.providingSSHKeyRadioButton}}
        {{#if useSSH}}
          {{t installer.step2.useSsh.provide}}
          <a href="javascript:void(null)"
             rel="popover"
            {{translateAttr title="installer.step2.useSsh.tooltip.title" data-content="installer.step2.useSsh.tooltip.content"}}>
            {{t installer.step2.useSsh.tooltip.title}}</a>
          {{t installer.step2.useSsh.provide_id_rsa}}
        {{else}}
          {{t installer.step2.install.perform}}
          <a href="javascript:void(null)"
             rel="popover"
            {{translateAttr title="installer.step2.automaticInstall.tooltip.title" data-content="installer.step2.automaticInstall.tooltip.content"}}>
            {{t installer.step2.automaticInstall.tooltip.title}}</a>
          {{t installer.step2.install.perform_on_hosts}}
        {{/if}}
      </label>

      {{#if useSSH}}
        <div class="ssh-key-input">
          {{#if view.isFileApi}}
            {{view App.SshKeyFileUploader disabledBinding="view.sshKeyState"}}
          {{/if}}
          <div {{bindAttr class="sshKeyError:error :controls :control-group"}}>
            {{view Ember.TextArea class="span6" rows="3" id="sshKey"
            placeholder="ssh private key" disabledBinding="view.sshKeyState" valueBinding="content.installOptions.sshKey"}}
            {{#if sshKeyError}}
              <span class="help-inline">{{sshKeyError}}</span>
            {{/if}}
          </div>
          <div class="row-fluid">
            <label rel="tooltip" {{translateAttr title="installer.step2.sshUser.toolTip"}} class="ssh-user pull-left span4">
              {{t installer.step2.sshUser}}
            </label>

            <div {{bindAttr class="sshUserError:error :control-group"}}>
              {{view view.textFieldView valueBinding="content.installOptions.sshUser" isEnabledBinding="content.installOptions.useSsh"}}
              {{#if sshUserError}}
                <span class="help-inline">{{sshUserError}}</span>
              {{/if}}
            </div>
          </div>
           <div class="row-fluid">
                <label rel="tooltip" {{translateAttr title="installer.step2.sshPort.toolTip"}} class="ssh-port pull-left span4">
                    {{t installer.step2.sshPort}}
                </label>

                <div {{bindAttr class="sshPortError:error :control-group"}}>
                    {{view view.textFieldView valueBinding="content.installOptions.sshPort" isEnabledBinding="content.installOptions.useSsh" }}
                    {{#if sshPortError}}
                        <span class="help-inline">{{sshPortError}}</span>
                    {{/if}}
                </div>
           </div>
          {{#if App.supports.customizeAgentUserAccount}}
            <div class="row-fluid">
              <label rel="tooltip" {{translateAttr title="installer.step2.agentUser.toolTip"}} class="ssh-user pull-left span4">
                {{t installer.step2.agentUser}}
              </label>

              <div {{bindAttr class="agentUserError:error :control-group"}}>
                {{view view.textFieldView valueBinding="content.installOptions.agentUser" isEnabledBinding="content.installOptions.useSsh"}}
                {{#if agentUserError}}
                  <span class="help-inline">{{agentUserError}}</span>
                {{/if}}
              </div>
            </div>
          {{/if}}

        </div>
      {{/if}}

      <label class="radio">
        {{view view.manualRegistrationRadioButton}}
        {{t installer.step2.install.perform}}
        {{#if useSSH}}
          <a href="javascript:void(null)"
             rel="popover"
            {{translateAttr title="installer.step2.manualInstall.tooltip.title" data-content="installer.step2.manualInstall.tooltip.content"}}>
            {{t installer.step2.manualInstall.tooltip.title}}</a>
        {{else}}
          <a href="javascript:void(null)"
             rel="popover"
            {{translateAttr title="installer.step2.manualInstall.tooltip.title" data-content="installer.step2.manualInstall.tooltip.content_no_ssh"}}>
            {{t installer.step2.manualInstall.tooltip.title}}</a>
        {{/if}}
        {{t installer.step2.install.perform_on_hosts}}
        {{#if useSSH}}
          {{t installer.step2.install.without_ssh}}
        {{/if}}
      </label>

    </div>
  </div>

  <div class="btn-area">
    {{#unless view.parentView.controller.hideBackButton}}
      <button class="btn pull-left installer-back-btn" {{action back}} {{bindAttr disabled="App.router.btnClickInProgress"}}>
        &larr; {{t common.back}}
        {{#if App.router.backBtnClickInProgress}}
          {{view App.SpinnerView tagName="span" classNames="service-button-spinner"}}
        {{/if}}
      </button>
    {{/unless}}
    <button class="btn btn-success pull-right" {{bindAttr disabled="isSubmitDisabled"}} {{action evaluateStep target="controller"}}>
      {{#if App.router.nextBtnClickInProgress}}
        {{view App.SpinnerView tagName="span" classNames="service-button-spinner"}}
      {{/if}}
      {{t installer.step2.registerAndConfirm}} &rarr;
    </button>
  </div>

</div>
